package com.chuanyang.driverh.mainhome.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.mainhome.DriverJoinActivity;
import com.chuanyang.driverh.response2.join.ResultDriverApplyList;
import com.chuanyang.driverh.response2.join.ResultFleetJoinList;
import com.chuanyang.driverh.responseresult.Result;
import com.chuanyang.driverh.utils.BitmapUtil;
import com.chuanyang.driverh.utils.DialogUtil;
import com.chuanyang.driverh.utils.LogUtils;
import com.chuanyang.driverh.utils.SharedPrefUtil;
import com.chuanyang.driverh.utils.net.JsonGenericsSerializator;
import com.chuanyang.driverh.utils.net.MyCallback;
import com.chuanyang.driverh.utils.net.MyHttpUtil;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;


public class DriverJoinApplyAdapter extends BaseListAdapter<ResultDriverApplyList.DataBean>{
    private Context mContext;

    private HuLueClickListener mListener;
    private JieShouClickListener mListener1;


    public DriverJoinApplyAdapter(Context context,HuLueClickListener listener,JieShouClickListener listener1) {
        super(context);//此处不传入集合，则默认集合长度为0，在setdataresult（）方法中，添加数据并刷新
        this.mContext = context;
        this.mListener = listener;
        this.mListener1 = listener1;
    }

    @Override
    public View getZkView(final int position, View convertView, final ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = getInflater().inflate(R.layout.driver_apply_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.iv_photo = (ImageView) convertView.findViewById(R.id.iv_photo);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);

            viewHolder.tv_jiameng_num = (TextView) convertView.findViewById(R.id.tv_jiameng_num);
            viewHolder.tv_shenqing_jiameng = (TextView) convertView.findViewById(R.id.tv_shenqing_jiameng);
            viewHolder.btn_hulue = (Button) convertView.findViewById(R.id.btn_hulue);
            viewHolder.btn_jieshou = (Button) convertView.findViewById(R.id.btn_jieshou);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final ResultDriverApplyList.DataBean data = getItem(position);

        //BitmapUtil.showImgForNetPath(data.getImage(), viewHolder.iv_photo);
        viewHolder.tv_title.setText(data.getFleetName());
//        viewHolder.tv_title.setText(data.getFleetName());
//        viewHolder.tv_title.setText(data.getFleetName());
//        viewHolder.tv_title.setText(data.getFleetName());
        viewHolder.btn_hulue.setOnClickListener(mListener);
        viewHolder.btn_hulue.setTag(position);

        viewHolder.btn_jieshou.setOnClickListener(mListener1);
        viewHolder.btn_jieshou.setTag(position);

        return convertView;
    }

    class ViewHolder {
        ImageView iv_photo;
        TextView tv_title;
        TextView tv_jiameng_num;
        TextView tv_shenqing_jiameng;
        Button btn_hulue;
        Button btn_jieshou;
    }

    public static abstract class HuLueClickListener implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            mListener((Integer) v.getTag(), v);
        }
        public abstract void mListener(int position, View v);
    }
    public static abstract class JieShouClickListener implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            mListener1((Integer) v.getTag(), v);
        }
        public abstract void mListener1(int position, View v);
    }


}
